function value = IsClosest(P,S,mode)

P_color = P{2};
P_num = P{3};
value = true;

B = S{1};
B_X = B{1}(1);
B_Y = B{1}(2);

P_X = P{1}(1);
P_Y = P{1}(2);
dist = sqrt((B_X-P_X)^2+(B_Y-P_Y)^2);

for k=2:numel(S) % check teammates
    if(S{k}{2} == P_color && S{k}{3} ~= P_num) % you are seeing a teammate


        Sk=S{k};
        Sk_X=Sk{1}(1);
        Sk_Y=Sk{1}(2);

        dist2=sqrt((B_X-Sk_X)^2+(B_Y-Sk_Y)^2);    %compute the distance to the ball from that mate

        if(dist2 < dist) % mate is closer to the ball so choose get open
            value = false;
            break; % no need to go through the rest of the teammates
        else
            continue;
        end

    end

end

end